package org.redis.cluster.config;

import java.io.Serializable;

public class ServerConfig implements Serializable {
	
	private String id;
	private String server;
	private String host;
	private Integer port;
	private Integer thread;
	private Integer bufferSize;
	private Integer timeout;
	private Integer connection;
	
	public ServerConfig() {
		this.id=initId();
	}
	
	protected String initId() {
		return IdGenerator.getId();
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getServer() {
		return server;
	}

	public void setServer(String server) {
		this.server = server;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	public Integer getThread() {
		return thread;
	}

	public void setThread(Integer thread) {
		this.thread = thread;
	}

	public Integer getBufferSize() {
		return bufferSize;
	}

	public void setBufferSize(Integer bufferSize) {
		this.bufferSize = bufferSize;
	}

	public Integer getTimeout() {
		return timeout;
	}

	public void setTimeout(Integer timeout) {
		this.timeout = timeout;
	}

	public Integer getConnection() {
		return connection;
	}

	public void setConnection(Integer connection) {
		this.connection = connection;
	}
	
	@Override
	public int hashCode() {
		return getId().hashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		return ((ServerConfig)obj).getId().equals(getId());
	}

	@Override
	public String toString() {
		return String.format("{id:%s,port:%s,thread:%s,bufferSize:%s,timeout:%s,connection:%s}", 
				getId(),getPort(),getThread(),getBufferSize(),getTimeout(),getConnection());
	}
}